/*** This dofile runs all of the code
to create the data for the 
Microgeography of Housing Supply ***/


*********** 1. Process Various Data Sources **************
cd other_data
*** Organize municipality-tract xwalks and regulation data
*Using land area allocations (secondary source)
cd wharton_lri/landarea_alloc
do merge_WRLURI_geocorr.do
*Using population allocations (primary source)
cd ../pop_alloc
do merge_WRLURI_geocorr.do
*** Organize satellite data
cd ../pct_developed/code
do land_coverage.do
*** Saiz replication
cd ../../saiz_replication/do
do generate_data.do
do replication.do

cd ../../../

************ 2. Create relevant geographies *************
cd crosswalks
do master-xwalks.do
*** Create 2000-2010 tracts crosswalk for use in Part 5 below
cd tracts20102000
do convert_2010_to_2000.do

cd ../..

********* 3. Create market access variables ************
cd market_access
do master_ma.do
cd ..

******* 4. Create zillow data output (data is suppressed for confidentiality) ******
cd zillow
do master_zillow.do
cd ..

******* 5. Spatially join landcover data to zillow new construction data *******
***** (New construction data is suppressed for confidentiality.) ***************
cd nlcdb01/code
*** This block of code uses R
!module load anaconda/3.5.3
!source activate r4_env
!nohup Rscript assign_LU2000_newcons.R &> assign_LU2000_newcons_log.txt &
!source deactivate
*Collapse down to a tract level dataset
do clean_zillow.do 
cd ../..

******* 6. Put everything together to form the final data set ************************
cd combined
do prepare_data_hs.do
cd ..

